<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>LCOV - code analysis - /usr/include/gflags/gflags.h</title>
  <link rel="stylesheet" type="text/css" href="../../../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LCOV - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../../../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
          <tr>
            <td width="10%" class="headerItem">Current view:</td>
            <td width="35%" class="headerValue"><a href="../../../index.html">top level</a> - <a href="index.html">usr/include/gflags</a> - gflags.h<span style="font-size: 80%;"> (source / <a href="gflags.h.func-sort-c.html">functions</a>)</span></td>
            <td width="5%"></td>
            <td width="15%"></td>
            <td width="10%" class="headerCovTableHead">Hit</td>
            <td width="10%" class="headerCovTableHead">Total</td>
            <td width="15%" class="headerCovTableHead">Coverage</td>
          </tr>
          <tr>
            <td class="headerItem">Test:</td>
            <td class="headerValue">code analysis</td>
            <td></td>
            <td class="headerItem">Lines:</td>
            <td class="headerCovTableEntry">1</td>
            <td class="headerCovTableEntry">1</td>
            <td class="headerCovTableEntryHi">100.0 %</td>
          </tr>
          <tr>
            <td class="headerItem">Date:</td>
            <td class="headerValue">2020-09-11 22:25:26</td>
            <td></td>
            <td class="headerItem">Functions:</td>
            <td class="headerCovTableEntry">0</td>
            <td class="headerCovTableEntry">0</td>
            <td class="headerCovTableEntryHi">-</td>
          </tr>
          <tr>
            <td class="headerItem">Legend:</td>
            <td class="headerValueLeg">            Lines:
            <span class="coverLegendCov">hit</span>
            <span class="coverLegendNoCov">not hit</span>
</td>
            <td></td>
          </tr>
          <tr><td><img src="../../../glass.png" width=3 height=3 alt=""></td></tr>
        </table>
      </td>
    </tr>

    <tr><td class="ruler"><img src="../../../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td>
<pre class="sourceHeading">          Line data    Source code</pre>
<pre class="source">
<a name="1"><span class="lineNum">       1 </span>            : // Copyright (c) 2006, Google Inc.</a>
<span class="lineNum">       2 </span>            : // All rights reserved.
<span class="lineNum">       3 </span>            : //
<span class="lineNum">       4 </span>            : // Redistribution and use in source and binary forms, with or without
<span class="lineNum">       5 </span>            : // modification, are permitted provided that the following conditions are
<span class="lineNum">       6 </span>            : // met:
<span class="lineNum">       7 </span>            : //
<span class="lineNum">       8 </span>            : //     * Redistributions of source code must retain the above copyright
<span class="lineNum">       9 </span>            : // notice, this list of conditions and the following disclaimer.
<span class="lineNum">      10 </span>            : //     * Redistributions in binary form must reproduce the above
<span class="lineNum">      11 </span>            : // copyright notice, this list of conditions and the following disclaimer
<span class="lineNum">      12 </span>            : // in the documentation and/or other materials provided with the
<span class="lineNum">      13 </span>            : // distribution.
<span class="lineNum">      14 </span>            : //     * Neither the name of Google Inc. nor the names of its
<span class="lineNum">      15 </span>            : // contributors may be used to endorse or promote products derived from
<span class="lineNum">      16 </span>            : // this software without specific prior written permission.
<span class="lineNum">      17 </span>            : //
<span class="lineNum">      18 </span>            : // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
<span class="lineNum">      19 </span>            : // &quot;AS IS&quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
<span class="lineNum">      20 </span>            : // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
<span class="lineNum">      21 </span>            : // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
<span class="lineNum">      22 </span>            : // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
<span class="lineNum">      23 </span>            : // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
<span class="lineNum">      24 </span>            : // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
<span class="lineNum">      25 </span>            : // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
<span class="lineNum">      26 </span>            : // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
<span class="lineNum">      27 </span>            : // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
<span class="lineNum">      28 </span>            : // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<span class="lineNum">      29 </span>            : 
<span class="lineNum">      30 </span>            : // ---
<span class="lineNum">      31 </span>            : // Revamped and reorganized by Craig Silverstein
<span class="lineNum">      32 </span>            : //
<span class="lineNum">      33 </span>            : // This is the file that should be included by any file which declares
<span class="lineNum">      34 </span>            : // or defines a command line flag or wants to parse command line flags
<span class="lineNum">      35 </span>            : // or print a program usage message (which will include information about
<span class="lineNum">      36 </span>            : // flags).  Executive summary, in the form of an example foo.cc file:
<span class="lineNum">      37 </span>            : //
<span class="lineNum">      38 </span>            : //    #include &quot;foo.h&quot;         // foo.h has a line &quot;DECLARE_int32(start);&quot;
<span class="lineNum">      39 </span>            : //    #include &quot;validators.h&quot;  // hypothetical file defining ValidateIsFile()
<span class="lineNum">      40 </span>            : //
<span class="lineNum">      41 </span>            : //    DEFINE_int32(end, 1000, &quot;The last record to read&quot;);
<span class="lineNum">      42 </span>            : //
<span class="lineNum">      43 </span>            : //    DEFINE_string(filename, &quot;my_file.txt&quot;, &quot;The file to read&quot;);
<span class="lineNum">      44 </span>            : //    // Crash if the specified file does not exist.
<span class="lineNum">      45 </span>            : //    static bool dummy = RegisterFlagValidator(&amp;FLAGS_filename,
<span class="lineNum">      46 </span>            : //                                              &amp;ValidateIsFile);
<span class="lineNum">      47 </span>            : //
<span class="lineNum">      48 </span>            : //    DECLARE_bool(verbose); // some other file has a DEFINE_bool(verbose, ...)
<span class="lineNum">      49 </span>            : //
<span class="lineNum">      50 </span>            : //    void MyFunc() {
<span class="lineNum">      51 </span>            : //      if (FLAGS_verbose) printf(&quot;Records %d-%d\n&quot;, FLAGS_start, FLAGS_end);
<span class="lineNum">      52 </span>            : //    }
<span class="lineNum">      53 </span>            : //
<span class="lineNum">      54 </span>            : //    Then, at the command-line:
<span class="lineNum">      55 </span>            : //       ./foo --noverbose --start=5 --end=100
<span class="lineNum">      56 </span>            : //
<span class="lineNum">      57 </span>            : // For more details, see
<span class="lineNum">      58 </span>            : //    doc/gflags.html
<span class="lineNum">      59 </span>            : //
<span class="lineNum">      60 </span>            : // --- A note about thread-safety:
<span class="lineNum">      61 </span>            : //
<span class="lineNum">      62 </span>            : // We describe many functions in this routine as being thread-hostile,
<span class="lineNum">      63 </span>            : // thread-compatible, or thread-safe.  Here are the meanings we use:
<span class="lineNum">      64 </span>            : //
<span class="lineNum">      65 </span>            : // thread-safe: it is safe for multiple threads to call this routine
<span class="lineNum">      66 </span>            : //   (or, when referring to a class, methods of this class)
<span class="lineNum">      67 </span>            : //   concurrently.
<span class="lineNum">      68 </span>            : // thread-hostile: it is not safe for multiple threads to call this
<span class="lineNum">      69 </span>            : //   routine (or methods of this class) concurrently.  In gflags,
<span class="lineNum">      70 </span>            : //   most thread-hostile routines are intended to be called early in,
<span class="lineNum">      71 </span>            : //   or even before, main() -- that is, before threads are spawned.
<span class="lineNum">      72 </span>            : // thread-compatible: it is safe for multiple threads to read from
<span class="lineNum">      73 </span>            : //   this variable (when applied to variables), or to call const
<span class="lineNum">      74 </span>            : //   methods of this class (when applied to classes), as long as no
<span class="lineNum">      75 </span>            : //   other thread is writing to the variable or calling non-const
<span class="lineNum">      76 </span>            : //   methods of this class.
<span class="lineNum">      77 </span>            : 
<span class="lineNum">      78 </span>            : #ifndef GFLAGS_GFLAGS_H_
<span class="lineNum">      79 </span>            : #define GFLAGS_GFLAGS_H_
<span class="lineNum">      80 </span>            : 
<span class="lineNum">      81 </span>            : #include &lt;string&gt;
<span class="lineNum">      82 </span>            : #include &lt;vector&gt;
<span class="lineNum">      83 </span>            : 
<span class="lineNum">      84 </span>            : #include &quot;gflags_declare.h&quot; // IWYU pragma: export
<span class="lineNum">      85 </span>            : 
<span class="lineNum">      86 </span>            : 
<span class="lineNum">      87 </span>            : // We always want to export variables defined in user code
<span class="lineNum">      88 </span>            : #ifndef GFLAGS_DLL_DEFINE_FLAG
<span class="lineNum">      89 </span>            : #  ifdef _MSC_VER
<span class="lineNum">      90 </span>            : #    define GFLAGS_DLL_DEFINE_FLAG __declspec(dllexport)
<span class="lineNum">      91 </span>            : #  else
<span class="lineNum">      92 </span>            : #    define GFLAGS_DLL_DEFINE_FLAG
<span class="lineNum">      93 </span>            : #  endif
<span class="lineNum">      94 </span>            : #endif
<span class="lineNum">      95 </span>            : 
<span class="lineNum">      96 </span>            : 
<span class="lineNum">      97 </span>            : namespace GFLAGS_NAMESPACE {
<span class="lineNum">      98 </span>            : 
<span class="lineNum">      99 </span>            : 
<span class="lineNum">     100 </span>            : // --------------------------------------------------------------------
<span class="lineNum">     101 </span>            : // To actually define a flag in a file, use DEFINE_bool,
<span class="lineNum">     102 </span>            : // DEFINE_string, etc. at the bottom of this file.  You may also find
<span class="lineNum">     103 </span>            : // it useful to register a validator with the flag.  This ensures that
<span class="lineNum">     104 </span>            : // when the flag is parsed from the commandline, or is later set via
<span class="lineNum">     105 </span>            : // SetCommandLineOption, we call the validation function. It is _not_
<span class="lineNum">     106 </span>            : // called when you assign the value to the flag directly using the = operator.
<span class="lineNum">     107 </span>            : //
<span class="lineNum">     108 </span>            : // The validation function should return true if the flag value is valid, and
<span class="lineNum">     109 </span>            : // false otherwise. If the function returns false for the new setting of the
<span class="lineNum">     110 </span>            : // flag, the flag will retain its current value. If it returns false for the
<span class="lineNum">     111 </span>            : // default value, ParseCommandLineFlags() will die.
<span class="lineNum">     112 </span>            : //
<span class="lineNum">     113 </span>            : // This function is safe to call at global construct time (as in the
<span class="lineNum">     114 </span>            : // example below).
<span class="lineNum">     115 </span>            : //
<span class="lineNum">     116 </span>            : // Example use:
<span class="lineNum">     117 </span>            : //    static bool ValidatePort(const char* flagname, int32 value) {
<span class="lineNum">     118 </span>            : //       if (value &gt; 0 &amp;&amp; value &lt; 32768)   // value is ok
<span class="lineNum">     119 </span>            : //         return true;
<span class="lineNum">     120 </span>            : //       printf(&quot;Invalid value for --%s: %d\n&quot;, flagname, (int)value);
<span class="lineNum">     121 </span>            : //       return false;
<span class="lineNum">     122 </span>            : //    }
<span class="lineNum">     123 </span>            : //    DEFINE_int32(port, 0, &quot;What port to listen on&quot;);
<span class="lineNum">     124 </span>            : //    static bool dummy = RegisterFlagValidator(&amp;FLAGS_port, &amp;ValidatePort);
<span class="lineNum">     125 </span>            : 
<span class="lineNum">     126 </span>            : // Returns true if successfully registered, false if not (because the
<span class="lineNum">     127 </span>            : // first argument doesn't point to a command-line flag, or because a
<span class="lineNum">     128 </span>            : // validator is already registered for this flag).
<span class="lineNum">     129 </span>            : extern GFLAGS_DLL_DECL bool RegisterFlagValidator(const bool*        flag, bool (*validate_fn)(const char*, bool));
<span class="lineNum">     130 </span>            : extern GFLAGS_DLL_DECL bool RegisterFlagValidator(const int32*       flag, bool (*validate_fn)(const char*, int32));
<span class="lineNum">     131 </span>            : extern GFLAGS_DLL_DECL bool RegisterFlagValidator(const int64*       flag, bool (*validate_fn)(const char*, int64));
<span class="lineNum">     132 </span>            : extern GFLAGS_DLL_DECL bool RegisterFlagValidator(const uint64*      flag, bool (*validate_fn)(const char*, uint64));
<span class="lineNum">     133 </span>            : extern GFLAGS_DLL_DECL bool RegisterFlagValidator(const double*      flag, bool (*validate_fn)(const char*, double));
<span class="lineNum">     134 </span>            : extern GFLAGS_DLL_DECL bool RegisterFlagValidator(const std::string* flag, bool (*validate_fn)(const char*, const std::string&amp;));
<span class="lineNum">     135 </span>            : 
<span class="lineNum">     136 </span>            : // Convenience macro for the registration of a flag validator
<span class="lineNum">     137 </span>            : #define DEFINE_validator(name, validator) \
<span class="lineNum">     138 </span>            :     static const bool name##_validator_registered = \
<span class="lineNum">     139 </span>            :             GFLAGS_NAMESPACE::RegisterFlagValidator(&amp;FLAGS_##name, validator)
<span class="lineNum">     140 </span>            : 
<span class="lineNum">     141 </span>            : 
<span class="lineNum">     142 </span>            : // --------------------------------------------------------------------
<span class="lineNum">     143 </span>            : // These methods are the best way to get access to info about the
<span class="lineNum">     144 </span>            : // list of commandline flags.  Note that these routines are pretty slow.
<span class="lineNum">     145 </span>            : //   GetAllFlags: mostly-complete info about the list, sorted by file.
<span class="lineNum">     146 </span>            : //   ShowUsageWithFlags: pretty-prints the list to stdout (what --help does)
<span class="lineNum">     147 </span>            : //   ShowUsageWithFlagsRestrict: limit to filenames with restrict as a substr
<span class="lineNum">     148 </span>            : //
<span class="lineNum">     149 </span>            : // In addition to accessing flags, you can also access argv[0] (the program
<span class="lineNum">     150 </span>            : // name) and argv (the entire commandline), which we sock away a copy of.
<span class="lineNum">     151 </span>            : // These variables are static, so you should only set them once.
<span class="lineNum">     152 </span>            : //
<span class="lineNum">     153 </span>            : // No need to export this data only structure from DLL, avoiding VS warning 4251.
<span class="lineNum">     154 </span>            : struct CommandLineFlagInfo {
<span class="lineNum">     155 </span>            :   std::string name;            // the name of the flag
<span class="lineNum">     156 </span>            :   std::string type;            // the type of the flag: int32, etc
<span class="lineNum">     157 </span>            :   std::string description;     // the &quot;help text&quot; associated with the flag
<span class="lineNum">     158 </span>            :   std::string current_value;   // the current value, as a string
<span class="lineNum">     159 </span>            :   std::string default_value;   // the default value, as a string
<span class="lineNum">     160 </span>            :   std::string filename;        // 'cleaned' version of filename holding the flag
<span class="lineNum">     161 </span>            :   bool has_validator_fn;       // true if RegisterFlagValidator called on this flag
<span class="lineNum">     162 </span>            :   bool is_default;             // true if the flag has the default value and
<span class="lineNum">     163 </span>            :                                // has not been set explicitly from the cmdline
<span class="lineNum">     164 </span>            :                                // or via SetCommandLineOption
<span class="lineNum">     165 </span>            :   const void* flag_ptr;        // pointer to the flag's current value (i.e. FLAGS_foo)
<span class="lineNum">     166 </span>            : };
<span class="lineNum">     167 </span>            : 
<span class="lineNum">     168 </span>            : // Using this inside of a validator is a recipe for a deadlock.
<span class="lineNum">     169 </span>            : // TODO(user) Fix locking when validators are running, to make it safe to
<span class="lineNum">     170 </span>            : // call validators during ParseAllFlags.
<span class="lineNum">     171 </span>            : // Also make sure then to uncomment the corresponding unit test in
<span class="lineNum">     172 </span>            : // gflags_unittest.sh
<span class="lineNum">     173 </span>            : extern GFLAGS_DLL_DECL void GetAllFlags(std::vector&lt;CommandLineFlagInfo&gt;* OUTPUT);
<span class="lineNum">     174 </span>            : // These two are actually defined in gflags_reporting.cc.
<span class="lineNum">     175 </span>            : extern GFLAGS_DLL_DECL void ShowUsageWithFlags(const char *argv0);  // what --help does
<span class="lineNum">     176 </span>            : extern GFLAGS_DLL_DECL void ShowUsageWithFlagsRestrict(const char *argv0, const char *restrict);
<span class="lineNum">     177 </span>            : 
<span class="lineNum">     178 </span>            : // Create a descriptive string for a flag.
<span class="lineNum">     179 </span>            : // Goes to some trouble to make pretty line breaks.
<span class="lineNum">     180 </span>            : extern GFLAGS_DLL_DECL std::string DescribeOneFlag(const CommandLineFlagInfo&amp; flag);
<span class="lineNum">     181 </span>            : 
<span class="lineNum">     182 </span>            : // Thread-hostile; meant to be called before any threads are spawned.
<span class="lineNum">     183 </span>            : extern GFLAGS_DLL_DECL void SetArgv(int argc, const char** argv);
<span class="lineNum">     184 </span>            : 
<span class="lineNum">     185 </span>            : // The following functions are thread-safe as long as SetArgv() is
<span class="lineNum">     186 </span>            : // only called before any threads start.
<span class="lineNum">     187 </span>            : extern GFLAGS_DLL_DECL const std::vector&lt;std::string&gt;&amp; GetArgvs();
<span class="lineNum">     188 </span>            : extern GFLAGS_DLL_DECL const char* GetArgv();                      // all of argv as a string
<span class="lineNum">     189 </span>            : extern GFLAGS_DLL_DECL const char* GetArgv0();                     // only argv0
<span class="lineNum">     190 </span>            : extern GFLAGS_DLL_DECL uint32 GetArgvSum();                        // simple checksum of argv
<span class="lineNum">     191 </span>            : extern GFLAGS_DLL_DECL const char* ProgramInvocationName();        // argv0, or &quot;UNKNOWN&quot; if not set
<span class="lineNum">     192 </span>            : extern GFLAGS_DLL_DECL const char* ProgramInvocationShortName();   // basename(argv0)
<span class="lineNum">     193 </span>            : 
<span class="lineNum">     194 </span>            : // ProgramUsage() is thread-safe as long as SetUsageMessage() is only
<span class="lineNum">     195 </span>            : // called before any threads start.
<span class="lineNum">     196 </span>            : extern GFLAGS_DLL_DECL const char* ProgramUsage();                 // string set by SetUsageMessage()
<span class="lineNum">     197 </span>            : 
<span class="lineNum">     198 </span>            : // VersionString() is thread-safe as long as SetVersionString() is only
<span class="lineNum">     199 </span>            : // called before any threads start.
<span class="lineNum">     200 </span>            : extern GFLAGS_DLL_DECL const char* VersionString();                // string set by SetVersionString()
<span class="lineNum">     201 </span>            : 
<span class="lineNum">     202 </span>            : 
<span class="lineNum">     203 </span>            : 
<span class="lineNum">     204 </span>            : // --------------------------------------------------------------------
<span class="lineNum">     205 </span>            : // Normally you access commandline flags by just saying &quot;if (FLAGS_foo)&quot;
<span class="lineNum">     206 </span>            : // or whatever, and set them by calling &quot;FLAGS_foo = bar&quot; (or, more
<span class="lineNum">     207 </span>            : // commonly, via the DEFINE_foo macro).  But if you need a bit more
<span class="lineNum">     208 </span>            : // control, we have programmatic ways to get/set the flags as well.
<span class="lineNum">     209 </span>            : // These programmatic ways to access flags are thread-safe, but direct
<span class="lineNum">     210 </span>            : // access is only thread-compatible.
<span class="lineNum">     211 </span>            : 
<span class="lineNum">     212 </span>            : // Return true iff the flagname was found.
<span class="lineNum">     213 </span>            : // OUTPUT is set to the flag's value, or unchanged if we return false.
<span class="lineNum">     214 </span>            : extern GFLAGS_DLL_DECL bool GetCommandLineOption(const char* name, std::string* OUTPUT);
<span class="lineNum">     215 </span>            : 
<span class="lineNum">     216 </span>            : // Return true iff the flagname was found. OUTPUT is set to the flag's
<span class="lineNum">     217 </span>            : // CommandLineFlagInfo or unchanged if we return false.
<span class="lineNum">     218 </span>            : extern GFLAGS_DLL_DECL bool GetCommandLineFlagInfo(const char* name, CommandLineFlagInfo* OUTPUT);
<span class="lineNum">     219 </span>            : 
<span class="lineNum">     220 </span>            : // Return the CommandLineFlagInfo of the flagname.  exit() if name not found.
<span class="lineNum">     221 </span>            : // Example usage, to check if a flag's value is currently the default value:
<span class="lineNum">     222 </span>            : //   if (GetCommandLineFlagInfoOrDie(&quot;foo&quot;).is_default) ...
<span class="lineNum">     223 </span>            : extern GFLAGS_DLL_DECL CommandLineFlagInfo GetCommandLineFlagInfoOrDie(const char* name);
<span class="lineNum">     224 </span>            : 
<span class="lineNum">     225 </span>            : enum GFLAGS_DLL_DECL FlagSettingMode {
<span class="lineNum">     226 </span>            :   // update the flag's value (can call this multiple times).
<span class="lineNum">     227 </span>            :   SET_FLAGS_VALUE,
<span class="lineNum">     228 </span>            :   // update the flag's value, but *only if* it has not yet been updated
<span class="lineNum">     229 </span>            :   // with SET_FLAGS_VALUE, SET_FLAG_IF_DEFAULT, or &quot;FLAGS_xxx = nondef&quot;.
<span class="lineNum">     230 </span>            :   SET_FLAG_IF_DEFAULT,
<span class="lineNum">     231 </span>            :   // set the flag's default value to this.  If the flag has not yet updated
<span class="lineNum">     232 </span>            :   // yet (via SET_FLAGS_VALUE, SET_FLAG_IF_DEFAULT, or &quot;FLAGS_xxx = nondef&quot;)
<span class="lineNum">     233 </span>            :   // change the flag's current value to the new default value as well.
<span class="lineNum">     234 </span>            :   SET_FLAGS_DEFAULT
<span class="lineNum">     235 </span>            : };
<span class="lineNum">     236 </span>            : 
<span class="lineNum">     237 </span>            : // Set a particular flag (&quot;command line option&quot;).  Returns a string
<span class="lineNum">     238 </span>            : // describing the new value that the option has been set to.  The
<span class="lineNum">     239 </span>            : // return value API is not well-specified, so basically just depend on
<span class="lineNum">     240 </span>            : // it to be empty if the setting failed for some reason -- the name is
<span class="lineNum">     241 </span>            : // not a valid flag name, or the value is not a valid value -- and
<span class="lineNum">     242 </span>            : // non-empty else.
<span class="lineNum">     243 </span>            : 
<span class="lineNum">     244 </span>            : // SetCommandLineOption uses set_mode == SET_FLAGS_VALUE (the common case)
<span class="lineNum">     245 </span>            : extern GFLAGS_DLL_DECL std::string SetCommandLineOption        (const char* name, const char* value);
<span class="lineNum">     246 </span>            : extern GFLAGS_DLL_DECL std::string SetCommandLineOptionWithMode(const char* name, const char* value, FlagSettingMode set_mode);
<span class="lineNum">     247 </span>            : 
<span class="lineNum">     248 </span>            : 
<span class="lineNum">     249 </span>            : // --------------------------------------------------------------------
<span class="lineNum">     250 </span>            : // Saves the states (value, default value, whether the user has set
<span class="lineNum">     251 </span>            : // the flag, registered validators, etc) of all flags, and restores
<span class="lineNum">     252 </span>            : // them when the FlagSaver is destroyed.  This is very useful in
<span class="lineNum">     253 </span>            : // tests, say, when you want to let your tests change the flags, but
<span class="lineNum">     254 </span>            : // make sure that they get reverted to the original states when your
<span class="lineNum">     255 </span>            : // test is complete.
<span class="lineNum">     256 </span>            : //
<span class="lineNum">     257 </span>            : // Example usage:
<span class="lineNum">     258 </span>            : //   void TestFoo() {
<span class="lineNum">     259 </span>            : //     FlagSaver s1;
<span class="lineNum">     260 </span>            : //     FLAG_foo = false;
<span class="lineNum">     261 </span>            : //     FLAG_bar = &quot;some value&quot;;
<span class="lineNum">     262 </span>            : //
<span class="lineNum">     263 </span>            : //     // test happens here.  You can return at any time
<span class="lineNum">     264 </span>            : //     // without worrying about restoring the FLAG values.
<span class="lineNum">     265 </span>            : //   }
<span class="lineNum">     266 </span>            : //
<span class="lineNum">     267 </span>            : // Note: This class is marked with GFLAGS_ATTRIBUTE_UNUSED because all
<span class="lineNum">     268 </span>            : // the work is done in the constructor and destructor, so in the standard
<span class="lineNum">     269 </span>            : // usage example above, the compiler would complain that it's an
<span class="lineNum">     270 </span>            : // unused variable.
<span class="lineNum">     271 </span>            : //
<span class="lineNum">     272 </span>            : // This class is thread-safe.  However, its destructor writes to
<span class="lineNum">     273 </span>            : // exactly the set of flags that have changed value during its
<span class="lineNum">     274 </span>            : // lifetime, so concurrent _direct_ access to those flags
<span class="lineNum">     275 </span>            : // (i.e. FLAGS_foo instead of {Get,Set}CommandLineOption()) is unsafe.
<span class="lineNum">     276 </span>            : 
<span class="lineNum">     277 </span>            : class GFLAGS_DLL_DECL FlagSaver {
<span class="lineNum">     278 </span>            :  public:
<span class="lineNum">     279 </span>            :   FlagSaver();
<span class="lineNum">     280 </span>            :   ~FlagSaver();
<span class="lineNum">     281 </span>            : 
<span class="lineNum">     282 </span>            :  private:
<span class="lineNum">     283 </span>            :   class FlagSaverImpl* impl_;   // we use pimpl here to keep API steady
<span class="lineNum">     284 </span>            : 
<span class="lineNum">     285 </span>            :   FlagSaver(const FlagSaver&amp;);  // no copying!
<span class="lineNum">     286 </span>            :   void operator=(const FlagSaver&amp;);
<span class="lineNum">     287 </span>            : }__attribute((unused));
<span class="lineNum">     288 </span>            : 
<span class="lineNum">     289 </span>            : // --------------------------------------------------------------------
<span class="lineNum">     290 </span>            : // Some deprecated or hopefully-soon-to-be-deprecated functions.
<span class="lineNum">     291 </span>            : 
<span class="lineNum">     292 </span>            : // This is often used for logging.  TODO(csilvers): figure out a better way
<span class="lineNum">     293 </span>            : extern GFLAGS_DLL_DECL std::string CommandlineFlagsIntoString();
<span class="lineNum">     294 </span>            : // Usually where this is used, a FlagSaver should be used instead.
<span class="lineNum">     295 </span>            : extern GFLAGS_DLL_DECL
<span class="lineNum">     296 </span>            : bool ReadFlagsFromString(const std::string&amp; flagfilecontents,
<span class="lineNum">     297 </span>            :                          const char* prog_name,
<span class="lineNum">     298 </span>            :                          bool errors_are_fatal);  // uses SET_FLAGS_VALUE
<span class="lineNum">     299 </span>            : 
<span class="lineNum">     300 </span>            : // These let you manually implement --flagfile functionality.
<span class="lineNum">     301 </span>            : // DEPRECATED.
<span class="lineNum">     302 </span>            : extern GFLAGS_DLL_DECL bool AppendFlagsIntoFile(const std::string&amp; filename, const char* prog_name);
<span class="lineNum">     303 </span>            : extern GFLAGS_DLL_DECL bool ReadFromFlagsFile(const std::string&amp; filename, const char* prog_name, bool errors_are_fatal);   // uses SET_FLAGS_VALUE
<span class="lineNum">     304 </span>            : 
<span class="lineNum">     305 </span>            : 
<span class="lineNum">     306 </span>            : // --------------------------------------------------------------------
<span class="lineNum">     307 </span>            : // Useful routines for initializing flags from the environment.
<span class="lineNum">     308 </span>            : // In each case, if 'varname' does not exist in the environment
<span class="lineNum">     309 </span>            : // return defval.  If 'varname' does exist but is not valid
<span class="lineNum">     310 </span>            : // (e.g., not a number for an int32 flag), abort with an error.
<span class="lineNum">     311 </span>            : // Otherwise, return the value.  NOTE: for booleans, for true use
<span class="lineNum">     312 </span>            : // 't' or 'T' or 'true' or '1', for false 'f' or 'F' or 'false' or '0'.
<span class="lineNum">     313 </span>            : 
<span class="lineNum">     314 </span>            : extern GFLAGS_DLL_DECL bool BoolFromEnv(const char *varname, bool defval);
<span class="lineNum">     315 </span>            : extern GFLAGS_DLL_DECL int32 Int32FromEnv(const char *varname, int32 defval);
<span class="lineNum">     316 </span>            : extern GFLAGS_DLL_DECL int64 Int64FromEnv(const char *varname, int64 defval);
<span class="lineNum">     317 </span>            : extern GFLAGS_DLL_DECL uint64 Uint64FromEnv(const char *varname, uint64 defval);
<span class="lineNum">     318 </span>            : extern GFLAGS_DLL_DECL double DoubleFromEnv(const char *varname, double defval);
<span class="lineNum">     319 </span>            : extern GFLAGS_DLL_DECL const char *StringFromEnv(const char *varname, const char *defval);
<span class="lineNum">     320 </span>            : 
<span class="lineNum">     321 </span>            : 
<span class="lineNum">     322 </span>            : // --------------------------------------------------------------------
<span class="lineNum">     323 </span>            : // The next two functions parse gflags from main():
<span class="lineNum">     324 </span>            : 
<span class="lineNum">     325 </span>            : // Set the &quot;usage&quot; message for this program.  For example:
<span class="lineNum">     326 </span>            : //   string usage(&quot;This program does nothing.  Sample usage:\n&quot;);
<span class="lineNum">     327 </span>            : //   usage += argv[0] + &quot; &lt;uselessarg1&gt; &lt;uselessarg2&gt;&quot;;
<span class="lineNum">     328 </span>            : //   SetUsageMessage(usage);
<span class="lineNum">     329 </span>            : // Do not include commandline flags in the usage: we do that for you!
<span class="lineNum">     330 </span>            : // Thread-hostile; meant to be called before any threads are spawned.
<span class="lineNum">     331 </span>            : extern GFLAGS_DLL_DECL void SetUsageMessage(const std::string&amp; usage);
<span class="lineNum">     332 </span>            : 
<span class="lineNum">     333 </span>            : // Sets the version string, which is emitted with --version.
<span class="lineNum">     334 </span>            : // For instance: SetVersionString(&quot;1.3&quot;);
<span class="lineNum">     335 </span>            : // Thread-hostile; meant to be called before any threads are spawned.
<span class="lineNum">     336 </span>            : extern GFLAGS_DLL_DECL void SetVersionString(const std::string&amp; version);
<span class="lineNum">     337 </span>            : 
<span class="lineNum">     338 </span>            : 
<span class="lineNum">     339 </span>            : // Looks for flags in argv and parses them.  Rearranges argv to put
<span class="lineNum">     340 </span>            : // flags first, or removes them entirely if remove_flags is true.
<span class="lineNum">     341 </span>            : // If a flag is defined more than once in the command line or flag
<span class="lineNum">     342 </span>            : // file, the last definition is used.  Returns the index (into argv)
<span class="lineNum">     343 </span>            : // of the first non-flag argument.
<span class="lineNum">     344 </span>            : // See top-of-file for more details on this function.
<span class="lineNum">     345 </span>            : #ifndef SWIG   // In swig, use ParseCommandLineFlagsScript() instead.
<span class="lineNum">     346 </span>            : extern GFLAGS_DLL_DECL uint32 ParseCommandLineFlags(int *argc, char*** argv, bool remove_flags);
<span class="lineNum">     347 </span>            : #endif
<span class="lineNum">     348 </span>            : 
<span class="lineNum">     349 </span>            : 
<span class="lineNum">     350 </span>            : // Calls to ParseCommandLineNonHelpFlags and then to
<span class="lineNum">     351 </span>            : // HandleCommandLineHelpFlags can be used instead of a call to
<span class="lineNum">     352 </span>            : // ParseCommandLineFlags during initialization, in order to allow for
<span class="lineNum">     353 </span>            : // changing default values for some FLAGS (via
<span class="lineNum">     354 </span>            : // e.g. SetCommandLineOptionWithMode calls) between the time of
<span class="lineNum">     355 </span>            : // command line parsing and the time of dumping help information for
<span class="lineNum">     356 </span>            : // the flags as a result of command line parsing.  If a flag is
<span class="lineNum">     357 </span>            : // defined more than once in the command line or flag file, the last
<span class="lineNum">     358 </span>            : // definition is used.  Returns the index (into argv) of the first
<span class="lineNum">     359 </span>            : // non-flag argument.  (If remove_flags is true, will always return 1.)
<span class="lineNum">     360 </span>            : extern GFLAGS_DLL_DECL uint32 ParseCommandLineNonHelpFlags(int *argc, char*** argv, bool remove_flags);
<span class="lineNum">     361 </span>            : 
<span class="lineNum">     362 </span>            : // This is actually defined in gflags_reporting.cc.
<span class="lineNum">     363 </span>            : // This function is misnamed (it also handles --version, etc.), but
<span class="lineNum">     364 </span>            : // it's too late to change that now. :-(
<span class="lineNum">     365 </span>            : extern GFLAGS_DLL_DECL void HandleCommandLineHelpFlags();   // in gflags_reporting.cc
<span class="lineNum">     366 </span>            : 
<span class="lineNum">     367 </span>            : // Allow command line reparsing.  Disables the error normally
<span class="lineNum">     368 </span>            : // generated when an unknown flag is found, since it may be found in a
<span class="lineNum">     369 </span>            : // later parse.  Thread-hostile; meant to be called before any threads
<span class="lineNum">     370 </span>            : // are spawned.
<span class="lineNum">     371 </span>            : extern GFLAGS_DLL_DECL void AllowCommandLineReparsing();
<span class="lineNum">     372 </span>            : 
<span class="lineNum">     373 </span>            : // Reparse the flags that have not yet been recognized.  Only flags
<span class="lineNum">     374 </span>            : // registered since the last parse will be recognized.  Any flag value
<span class="lineNum">     375 </span>            : // must be provided as part of the argument using &quot;=&quot;, not as a
<span class="lineNum">     376 </span>            : // separate command line argument that follows the flag argument.
<span class="lineNum">     377 </span>            : // Intended for handling flags from dynamically loaded libraries,
<span class="lineNum">     378 </span>            : // since their flags are not registered until they are loaded.
<span class="lineNum">     379 </span>            : extern GFLAGS_DLL_DECL void ReparseCommandLineNonHelpFlags();
<span class="lineNum">     380 </span>            : 
<span class="lineNum">     381 </span>            : // Clean up memory allocated by flags.  This is only needed to reduce
<span class="lineNum">     382 </span>            : // the quantity of &quot;potentially leaked&quot; reports emitted by memory
<span class="lineNum">     383 </span>            : // debugging tools such as valgrind.  It is not required for normal
<span class="lineNum">     384 </span>            : // operation, or for the google perftools heap-checker.  It must only
<span class="lineNum">     385 </span>            : // be called when the process is about to exit, and all threads that
<span class="lineNum">     386 </span>            : // might access flags are quiescent.  Referencing flags after this is
<span class="lineNum">     387 </span>            : // called will have unexpected consequences.  This is not safe to run
<span class="lineNum">     388 </span>            : // when multiple threads might be running: the function is
<span class="lineNum">     389 </span>            : // thread-hostile.
<span class="lineNum">     390 </span>            : extern GFLAGS_DLL_DECL void ShutDownCommandLineFlags();
<span class="lineNum">     391 </span>            : 
<span class="lineNum">     392 </span>            : 
<span class="lineNum">     393 </span>            : // --------------------------------------------------------------------
<span class="lineNum">     394 </span>            : // Now come the command line flag declaration/definition macros that
<span class="lineNum">     395 </span>            : // will actually be used.  They're kind of hairy.  A major reason
<span class="lineNum">     396 </span>            : // for this is initialization: we want people to be able to access
<span class="lineNum">     397 </span>            : // variables in global constructors and have that not crash, even if
<span class="lineNum">     398 </span>            : // their global constructor runs before the global constructor here.
<span class="lineNum">     399 </span>            : // (Obviously, we can't guarantee the flags will have the correct
<span class="lineNum">     400 </span>            : // default value in that case, but at least accessing them is safe.)
<span class="lineNum">     401 </span>            : // The only way to do that is have flags point to a static buffer.
<span class="lineNum">     402 </span>            : // So we make one, using a union to ensure proper alignment, and
<span class="lineNum">     403 </span>            : // then use placement-new to actually set up the flag with the
<span class="lineNum">     404 </span>            : // correct default value.  In the same vein, we have to worry about
<span class="lineNum">     405 </span>            : // flag access in global destructors, so FlagRegisterer has to be
<span class="lineNum">     406 </span>            : // careful never to destroy the flag-values it constructs.
<span class="lineNum">     407 </span>            : //
<span class="lineNum">     408 </span>            : // Note that when we define a flag variable FLAGS_&lt;name&gt;, we also
<span class="lineNum">     409 </span>            : // preemptively define a junk variable, FLAGS_no&lt;name&gt;.  This is to
<span class="lineNum">     410 </span>            : // cause a link-time error if someone tries to define 2 flags with
<span class="lineNum">     411 </span>            : // names like &quot;logging&quot; and &quot;nologging&quot;.  We do this because a bool
<span class="lineNum">     412 </span>            : // flag FLAG can be set from the command line to true with a &quot;-FLAG&quot;
<span class="lineNum">     413 </span>            : // argument, and to false with a &quot;-noFLAG&quot; argument, and so this can
<span class="lineNum">     414 </span>            : // potentially avert confusion.
<span class="lineNum">     415 </span>            : //
<span class="lineNum">     416 </span>            : // We also put flags into their own namespace.  It is purposefully
<span class="lineNum">     417 </span>            : // named in an opaque way that people should have trouble typing
<span class="lineNum">     418 </span>            : // directly.  The idea is that DEFINE puts the flag in the weird
<span class="lineNum">     419 </span>            : // namespace, and DECLARE imports the flag from there into the current
<span class="lineNum">     420 </span>            : // namespace.  The net result is to force people to use DECLARE to get
<span class="lineNum">     421 </span>            : // access to a flag, rather than saying &quot;extern GFLAGS_DLL_DECL bool FLAGS_whatever;&quot;
<span class="lineNum">     422 </span>            : // or some such instead.  We want this so we can put extra
<span class="lineNum">     423 </span>            : // functionality (like sanity-checking) in DECLARE if we want, and
<span class="lineNum">     424 </span>            : // make sure it is picked up everywhere.
<span class="lineNum">     425 </span>            : //
<span class="lineNum">     426 </span>            : // We also put the type of the variable in the namespace, so that
<span class="lineNum">     427 </span>            : // people can't DECLARE_int32 something that they DEFINE_bool'd
<span class="lineNum">     428 </span>            : // elsewhere.
<span class="lineNum">     429 </span>            : 
<span class="lineNum">     430 </span>            : class GFLAGS_DLL_DECL FlagRegisterer {
<span class="lineNum">     431 </span>            :  public:
<span class="lineNum">     432 </span>            :   FlagRegisterer(const char* name, const char* type,
<span class="lineNum">     433 </span>            :                  const char* help, const char* filename,
<span class="lineNum">     434 </span>            :                  void* current_storage, void* defvalue_storage);
<span class="lineNum">     435 </span>            : };
<span class="lineNum">     436 </span>            : 
<span class="lineNum">     437 </span>            : // If your application #defines STRIP_FLAG_HELP to a non-zero value
<span class="lineNum">     438 </span>            : // before #including this file, we remove the help message from the
<span class="lineNum">     439 </span>            : // binary file. This can reduce the size of the resulting binary
<span class="lineNum">     440 </span>            : // somewhat, and may also be useful for security reasons.
<span class="lineNum">     441 </span>            : 
<span class="lineNum">     442 </span>            : extern GFLAGS_DLL_DECL const char kStrippedFlagHelp[];
<span class="lineNum">     443 </span>            : 
<span class="lineNum">     444 </span>            : 
<span class="lineNum">     445 </span>            : } // namespace GFLAGS_NAMESPACE
<span class="lineNum">     446 </span>            : 
<span class="lineNum">     447 </span>            : 
<span class="lineNum">     448 </span>            : #ifndef SWIG  // In swig, ignore the main flag declarations
<span class="lineNum">     449 </span>            : 
<span class="lineNum">     450 </span>            : #if defined(STRIP_FLAG_HELP) &amp;&amp; STRIP_FLAG_HELP &gt; 0
<span class="lineNum">     451 </span>            : // Need this construct to avoid the 'defined but not used' warning.
<span class="lineNum">     452 </span>            : #define MAYBE_STRIPPED_HELP(txt) \
<span class="lineNum">     453 </span>            :    (false ? (txt) : GFLAGS_NAMESPACE::kStrippedFlagHelp)
<span class="lineNum">     454 </span>            : #else
<span class="lineNum">     455 </span>            : #define MAYBE_STRIPPED_HELP(txt) txt
<span class="lineNum">     456 </span>            : #endif
<span class="lineNum">     457 </span>            : 
<span class="lineNum">     458 </span>            : // Each command-line flag has two variables associated with it: one
<span class="lineNum">     459 </span>            : // with the current value, and one with the default value.  However,
<span class="lineNum">     460 </span>            : // we have a third variable, which is where value is assigned; it's a
<span class="lineNum">     461 </span>            : // constant.  This guarantees that FLAG_##value is initialized at
<span class="lineNum">     462 </span>            : // static initialization time (e.g. before program-start) rather than
<span class="lineNum">     463 </span>            : // than global construction time (which is after program-start but
<span class="lineNum">     464 </span>            : // before main), at least when 'value' is a compile-time constant.  We
<span class="lineNum">     465 </span>            : // use a small trick for the &quot;default value&quot; variable, and call it
<span class="lineNum">     466 </span>            : // FLAGS_no&lt;name&gt;.  This serves the second purpose of assuring a
<span class="lineNum">     467 </span>            : // compile error if someone tries to define a flag named no&lt;name&gt;
<span class="lineNum">     468 </span>            : // which is illegal (--foo and --nofoo both affect the &quot;foo&quot; flag).
<span class="lineNum">     469 </span>            : #define DEFINE_VARIABLE(type, shorttype, name, value, help)             \
<span class="lineNum">     470 </span>            :   namespace fL##shorttype {                                             \
<span class="lineNum">     471 </span>            :     static const type FLAGS_nono##name = value;                         \
<span class="lineNum">     472 </span>            :     /* We always want to export defined variables, dll or no */         \
<span class="lineNum">     473 </span>            :     GFLAGS_DLL_DEFINE_FLAG type FLAGS_##name = FLAGS_nono##name;        \
<span class="lineNum">     474 </span>            :     type FLAGS_no##name = FLAGS_nono##name;                             \
<span class="lineNum">     475 </span>            :     static GFLAGS_NAMESPACE::FlagRegisterer o_##name(                   \
<span class="lineNum">     476 </span>            :       #name, #type, MAYBE_STRIPPED_HELP(help), __FILE__,                \
<span class="lineNum">     477 </span>            :       &amp;FLAGS_##name, &amp;FLAGS_no##name);                                  \
<span class="lineNum">     478 </span>            :   }                                                                     \
<span class="lineNum">     479 </span>            :   using fL##shorttype::FLAGS_##name
<span class="lineNum">     480 </span>            : 
<span class="lineNum">     481 </span>            : // For DEFINE_bool, we want to do the extra check that the passed-in
<span class="lineNum">     482 </span>            : // value is actually a bool, and not a string or something that can be
<span class="lineNum">     483 </span>            : // coerced to a bool.  These declarations (no definition needed!) will
<span class="lineNum">     484 </span>            : // help us do that, and never evaluate From, which is important.
<span class="lineNum">     485 </span>            : // We'll use 'sizeof(IsBool(val))' to distinguish. This code requires
<span class="lineNum">     486 </span>            : // that the compiler have different sizes for bool &amp; double. Since
<span class="lineNum">     487 </span>            : // this is not guaranteed by the standard, we check it with a
<span class="lineNum">     488 </span>            : // COMPILE_ASSERT.
<span class="lineNum">     489 </span>            : namespace fLB {
<span class="lineNum">     490 </span>            : struct CompileAssert {};
<span class="lineNum">     491 </span>            : typedef CompileAssert expected_sizeof_double_neq_sizeof_bool[
<span class="lineNum">     492 </span>            :                       (sizeof(double) != sizeof(bool)) ? 1 : -1];
<span class="lineNum">     493 </span>            : template&lt;typename From&gt; double GFLAGS_DLL_DECL IsBoolFlag(const From&amp; from);
<span class="lineNum">     494 </span>            : GFLAGS_DLL_DECL bool IsBoolFlag(bool from);
<span class="lineNum">     495 </span>            : }  // namespace fLB
<span class="lineNum">     496 </span>            : 
<span class="lineNum">     497 </span>            : // Here are the actual DEFINE_*-macros. The respective DECLARE_*-macros
<span class="lineNum">     498 </span>            : // are in a separate include, gflags_declare.h, for reducing
<span class="lineNum">     499 </span>            : // the physical transitive size for DECLARE use.
<span class="lineNum">     500 </span>            : #define DEFINE_bool(name, val, txt)                                     \
<span class="lineNum">     501 </span>            :   namespace fLB {                                                       \
<span class="lineNum">     502 </span>            :     typedef ::fLB::CompileAssert FLAG_##name##_value_is_not_a_bool[     \
<span class="lineNum">     503 </span>            :             (sizeof(::fLB::IsBoolFlag(val)) != sizeof(double))? 1: -1]; \
<span class="lineNum">     504 </span>            :   }                                                                     \
<span class="lineNum">     505 </span>            :   DEFINE_VARIABLE(bool, B, name, val, txt)
<span class="lineNum">     506 </span>            : 
<span class="lineNum">     507 </span>            : #define DEFINE_int32(name, val, txt) \
<span class="lineNum">     508 </span>            :    DEFINE_VARIABLE(GFLAGS_NAMESPACE::int32, I, \
<span class="lineNum">     509 </span>            :                    name, val, txt)
<span class="lineNum">     510 </span>            : 
<span class="lineNum">     511 </span>            : #define DEFINE_int64(name, val, txt) \
<span class="lineNum">     512 </span>            :    DEFINE_VARIABLE(GFLAGS_NAMESPACE::int64, I64, \
<span class="lineNum">     513 </span>            :                    name, val, txt)
<span class="lineNum">     514 </span>            : 
<span class="lineNum">     515 </span>            : #define DEFINE_uint64(name,val, txt) \
<span class="lineNum">     516 </span>            :    DEFINE_VARIABLE(GFLAGS_NAMESPACE::uint64, U64, \
<span class="lineNum">     517 </span>            :                    name, val, txt)
<span class="lineNum">     518 </span>            : 
<span class="lineNum">     519 </span>            : #define DEFINE_double(name, val, txt) \
<span class="lineNum">     520 </span>            :    DEFINE_VARIABLE(double, D, name, val, txt)
<span class="lineNum">     521 </span>            : 
<span class="lineNum">     522 </span>            : // Strings are trickier, because they're not a POD, so we can't
<span class="lineNum">     523 </span>            : // construct them at static-initialization time (instead they get
<span class="lineNum">     524 </span>            : // constructed at global-constructor time, which is much later).  To
<span class="lineNum">     525 </span>            : // try to avoid crashes in that case, we use a char buffer to store
<span class="lineNum">     526 </span>            : // the string, which we can static-initialize, and then placement-new
<span class="lineNum">     527 </span>            : // into it later.  It's not perfect, but the best we can do.
<span class="lineNum">     528 </span>            : 
<span class="lineNum">     529 </span>            : namespace fLS {
<span class="lineNum">     530 </span>            : 
<span class="lineNum">     531 </span>            : inline clstring* dont_pass0toDEFINE_string(char *stringspot,
<span class="lineNum">     532 </span>            :                                            const char *value) {
<span class="lineNum">     533 </span><span class="lineCov">          9 :   return new(stringspot) clstring(value);</span>
<span class="lineNum">     534 </span>            : }
<span class="lineNum">     535 </span>            : inline clstring* dont_pass0toDEFINE_string(char *stringspot,
<span class="lineNum">     536 </span>            :                                            const clstring &amp;value) {
<span class="lineNum">     537 </span>            :   return new(stringspot) clstring(value);
<span class="lineNum">     538 </span>            : }
<span class="lineNum">     539 </span>            : inline clstring* dont_pass0toDEFINE_string(char *stringspot,
<span class="lineNum">     540 </span>            :                                            int value);
<span class="lineNum">     541 </span>            : }  // namespace fLS
<span class="lineNum">     542 </span>            : 
<span class="lineNum">     543 </span>            : // We need to define a var named FLAGS_no##name so people don't define
<span class="lineNum">     544 </span>            : // --string and --nostring.  And we need a temporary place to put val
<span class="lineNum">     545 </span>            : // so we don't have to evaluate it twice.  Two great needs that go
<span class="lineNum">     546 </span>            : // great together!
<span class="lineNum">     547 </span>            : // The weird 'using' + 'extern' inside the fLS namespace is to work around
<span class="lineNum">     548 </span>            : // an unknown compiler bug/issue with the gcc 4.2.1 on SUSE 10.  See
<span class="lineNum">     549 </span>            : //    http://code.google.com/p/google-gflags/issues/detail?id=20
<span class="lineNum">     550 </span>            : #define DEFINE_string(name, val, txt)                                       \
<span class="lineNum">     551 </span>            :   namespace fLS {                                                           \
<span class="lineNum">     552 </span>            :     using ::fLS::clstring;                                                  \
<span class="lineNum">     553 </span>            :     static union { void* align; char s[sizeof(clstring)]; } s_##name[2];    \
<span class="lineNum">     554 </span>            :     clstring* const FLAGS_no##name = ::fLS::                                \
<span class="lineNum">     555 </span>            :                                    dont_pass0toDEFINE_string(s_##name[0].s, \
<span class="lineNum">     556 </span>            :                                                              val);          \
<span class="lineNum">     557 </span>            :     static GFLAGS_NAMESPACE::FlagRegisterer o_##name(                       \
<span class="lineNum">     558 </span>            :         #name, &quot;string&quot;, MAYBE_STRIPPED_HELP(txt), __FILE__,                \
<span class="lineNum">     559 </span>            :         s_##name[0].s, new (s_##name[1].s) clstring(*FLAGS_no##name));      \
<span class="lineNum">     560 </span>            :     extern GFLAGS_DLL_DEFINE_FLAG clstring&amp; FLAGS_##name;                   \
<span class="lineNum">     561 </span>            :     using fLS::FLAGS_##name;                                                \
<span class="lineNum">     562 </span>            :     clstring&amp; FLAGS_##name = *FLAGS_no##name;                               \
<span class="lineNum">     563 </span>            :   }                                                                         \
<span class="lineNum">     564 </span>            :   using fLS::FLAGS_##name
<span class="lineNum">     565 </span>            : 
<span class="lineNum">     566 </span>            : #endif  // SWIG
<span class="lineNum">     567 </span>            : 
<span class="lineNum">     568 </span>            : 
<span class="lineNum">     569 </span>            : // Import gflags library symbols into alternative/deprecated namespace(s)
<span class="lineNum">     570 </span>            : #include &quot;gflags_gflags.h&quot;
<span class="lineNum">     571 </span>            : 
<span class="lineNum">     572 </span>            : 
<span class="lineNum">     573 </span>            : #endif  // GFLAGS_GFLAGS_H_
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="ruler"><img src="../../../glass.png" width=3 height=3 alt=""></td></tr>
    <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LCOV version 1.12</a></td></tr>
  </table>
  <br>

</body>
</html>
